package com.majun.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @author mj
 * @2025/2/9 22:02
 */
public class gitDiff {
    public static void main(String[] args) {
        gitDiffCommend();

    }
    ///ddddddddddddddddddddddddddddddddd
    public static void gitDiffCommend(){
        try {
            // 构建Git命令
            String[] command = {"git", "log"};

            // 执行命令并获取输出
            Process process = Runtime.getRuntime().exec(command);
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

            // 等待命令执行完成并检查退出码
            int exitCode = process.waitFor();
            if (exitCode != 0) {
                System.err.println("Git command failed with exit code: " + exitCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
